Skip to content

fix: strip literal <think> tags leaking into OpenCode response text#516

Merged
alari76 merged 1 commit into
mainfrom
fix/opencode-strip-think-tags
Jun 14, 2026
Merged

fix: strip literal <think> tags leaking into OpenCode response text#516
alari76 merged 1 commit into
mainfrom
fix/opencode-strip-think-tags

Conversation

@alari76

@alari76 alari76 commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Kimi k2.7 (ollama-cloud) sometimes wraps chain-of-thought in literal <think>...</think> tags inside a visible text part, so the existing part-kind classification (PR fix: use correct REST endpoint to classify OpenCode reasoning parts #515) can't hide it — the reasoning prose and a stray </think> tag showed up in the response.
  • Adds a streaming-safe filter in the text emission path of server/opencode-process.ts that strips <think>...</think> content (routing it to the reasoning/thinking buffer) and correctly handles tags split across multiple streaming deltas (e.g. <thi + nk>).

Test plan

  • npm test (server) — 99 tests pass, incl. two new regression tests:
    • strips <think>...</think> emitted inside a single text part
    • strips <think> tags split across multiple deltas
  • npm run build (typecheck) passes
  • Manual verification post-deploy: run a kimi k2.7 turn and confirm no <think> tags or reasoning prose in the transcript

🤖 Generated with Claude Code

Kimi k2.7 (ollama-cloud) sometimes wraps chain-of-thought in literal
<think>...</think> tags inside a visible text part, so part-kind
classification can't hide it. Add a streaming-safe filter that strips the
tags and routes their contents to the reasoning buffer, handling tags split
across deltas.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
@alari76
alari76 force-pushed the fix/opencode-strip-think-tags branch from 7d518a3 to 2ea75b5 Compare June 14, 2026 10:19
@alari76
alari76 merged commit 62e020d into main Jun 14, 2026
2 checks passed
@alari76
alari76 deleted the fix/opencode-strip-think-tags branch June 14, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant